/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Login;


import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

/**
 *
 * @author lab1
 */
@ManagedBean
@SessionScoped
public class beanUser {

    /** Creates a new instance of beanUser */
    private List<Users> listUser;
    //dung de show detail user
    private Users usdetail;
    private String optionsearch;
    private String valieSearch = "";
    private String checksearch = null;

    public String getOptionsearch() {
        return optionsearch;
    }

    public void setOptionsearch(String optionsearch) {
        this.optionsearch = optionsearch;
    }

    public String getValieSearch() {
        return valieSearch;
    }

    public void setValieSearch(String valieSearch) {
        this.valieSearch = valieSearch;
    }

    public Users getUsdetail() {
        return usdetail;
    }

    public void setUsdetail(Users usdetail) {
        this.usdetail = usdetail;
    }

    public beanUser() {
        listUser = boladmin.showAllUser();
    }
    BOLAdimUser boladmin = new BOLAdimUser();

    public List<Users> getListUser() {
        if (checksearch == null || valieSearch.equals("")) {

            listUser = boladmin.showAllUser();
        } else {
            listUser = boladmin.SearchUser(optionsearch, valieSearch);
        }
        return listUser;
    }

//    public String editUser(Users us)
//    {
//        us.setEditUser(true);
//        return null;
//    }
    public String delete(String id) {
        boladmin.DeleteUser(id);
        return null;
    }
    public String active(Users us) {
        boladmin.activeUser(us);
        this.getListUser();
        return null;
    }

    public String showDetail(Users us) {
        usdetail = us;
        return "DetailUser";
    }

    public String searchUser() {
        checksearch = "coroi";
        this.getListUser();
        return null;
    }
    public String resetUser() {
        checksearch = null;
        return null;
    }
}
